package com.thread;

public class SetThread implements Runnable{
     Student student;

    public SetThread(Student student) {
        this.student = student;
    }

    public void run() {
        int x=0;
/*        while (true)
        {
            synchronized (student)
            {
                if (student.isFlag()==true)
                {
                    try {
                        student.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                if(x%2==0)
                {
                    student.setAge("10");
                    student.setName("lj");
                }
                else
                {
                    student.setAge("20");
                    student.setName("xcy");
                }
                x++;
                student.setFlag(true);
                student.notify();
            }
        }*/
        while(true)
        {
                if(x%2==0)
                {
                    student.SetStudent("xcy","20");
                }
                else
                {
                    student.SetStudent("lj","10");

                }
                x++;
            }

    }
}
